package com.stupro.cjlu.controller;

import com.stupro.cjlu.common.vo.LoginVO;
import com.stupro.cjlu.common.vo.ResultVO;
import com.stupro.cjlu.service.UserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/user")
@RestController
public class UserController extends BaseController{
    private final UserService service;

    public UserController(UserService service) {
        this.service = service;
    }

    //登录功能后端接口
    @PostMapping("/login")
    public ResultVO login(@RequestBody LoginVO loginVO) {
        String username = loginVO.getUsername();
        String password = loginVO.getPassword();
        Integer userType = loginVO.getUserType();
        return service.login(username, password, userType);
    }

    //得到登录状态接口
    @GetMapping("/login/status")
    public ResultVO getLoginStatus() {
        return service.getLoginStatus();
    }

    //登录退出功能接口
    @GetMapping("/logout")
    public ResultVO logout() {
        return service.logout();
    }
}
